#!D:\SDK\python37\python.exe
import cgi
import os
import codecs
import sys

# 中文不乱码
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.buffer)

form = cgi.FieldStorage()
name = form.getvalue("name")
if name is None or name == "":
    name = "NoName"

print ("Content-type:text/html")
print()  # 空行,告诉服务器header结束
print("<meta charset=\"utf-8\">")
print('<head>')
print('<meta charset="utf-8">')
print('<title>python cgi</title>')
print('</head>')
print(name+"<BR/>")
print("<b>环境变量</b><br>")
print("<ul>")
for key in os.environ.keys():
    print ("<li><span style='color:green'>%30s </span> : %s </li>" % (key,os.environ[key]))
print("</ul>")
